<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script id="commonHead" type="text/html">
    <div>
      <h1>我是头部组件</h1>
      <button>按钮</button>
    </div>
  </script>
  <script src="./vue.js"></script>
  <script>
    
    const CommonHead = {
      template:"#commonHead",
      data () {
        return {
          num: 10
        }
      },
      methods: {
        addNum () {
          this.num++
        }
      },
      watch: {
        num(){
          console.log('值变化了')
        }
      },
      computed: {
        num2 () {
          return this.num*2
        }
      }
    }
    // 注册全局组件
    Vue.component("CommonHead", CommonHead)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>